#!/usr/bin/python3.4

import cgi, sys
form = cgi.FieldStorage()
print("Content-type: text/html")

#class dummy:
#    def __init__(self, s): self.value = s
#form = {"yourname" : dummy("qinke"), "rack" : dummy("bjrack01"), "youraction" : dummy("clearrack")}

html = """
<TITLE>乾颐堂安全试验台自动脚本</TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<H1>问候语</H1>
<HR>
<H4>你的姓名是 %(yourname)s</H4>
<H4>你选择的试验台是 %(rack)s</H4>
<H4>你选择的操作是 %(youraction)s</H4>
<HR>"""

data = {}
for field in ("yourname", "rack", "youraction"):
	if not field in form:
		data[field] = "(未知)"
	else:
		if not isinstance (form[field], list):
			data[field] = form[field].value
		else:
			values = [x.value for x in form[field]]
			data[field] = " and ".join(values)

print(html % data)